<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>搜索结果</title>
</head>
<body>
	<style type="text/css">
td {
	width: 240px;
	background-color: #C4E1FF;
	font-size: 13pt
}

td {
	text-align: center;
}
</style>
	<!-- BEGIN: load jquery -->
	<script language="javascript" type="text/javascript"
		src=<?php echo base_url("js/jqplot/jquery.js")?>></script>
	<!-- END: load jquery -->
	<script type="text/javascript">
$(
	function()
	{
		$(".send_req").click(
				function ()
				{
					alert("请求已发送给对方！");
				}
				);
	}
);
</script>

	<center>
		<table>
			<?php
			function translate_condition($condition_str)
			{
				$map = array(
						"by_user_name"=>"按用户姓名",
						"by_nick_name"=>"按用户昵称",
						"by_symptom"=>"按症状"
				);

				if(!array_key_exists($condition_str, $map))
					return "未知条件";

				return $map[$condition_str];
			}



			function show_friend_or_care_td($uid)
			{
				$isFriend = is_friend(get_uid(), $uid);
				echo "<td class=\"status\">";
				if($isFriend)
				{
					echo "朋友";
				}
				else
				{
					$myUid = get_uid();
					$friendUid = $uid;
						
					$url = site_url("request_manage/send_request/$myUid/$friendUid");
						
					echo "<a class=\"send_req\" href=".$url.'>'."关心"."</a>";
				}
				echo "</td>";
			}

			function show_user_hyper_link($nick_name, $uid)
			{
				echo "<td>";
				echo "<a href=\"".site_url("search/show_user_analyse/$uid")."\">";
				echo $nick_name;
				echo "</a>";
				echo "</td>";
			}


			if(isset($rows)){
				foreach($rows as $record)
				{
					echo "<tr>";
					$nick_name = get_user_nick_name($record->uid);
					$full_name = $record->lastName.$record->firstName;

					show_user_hyper_link($nick_name, $record->uid);

					echo "<td>";
					echo $full_name;
					echo "</td>";

					show_friend_or_care_td($record->uid);

					echo "</tr>";
				}

				exit();

			}


			$duplicate_test = array();

			if(isset($relevant_user))
			{
				foreach ($relevant_user as $condition=>$uid_ary){
					if(!$uid_ary)
						continue;
					for(; $uid = current($uid_ary); next($uid_ary)){
						if(in_array($uid, $duplicate_test))
							continue;
							

							
						if($uid == get_uid())
							continue;
							
							
						$duplicate_test[] = $uid;
							
						$nick_name = get_user_nick_name($uid);
						$full_name = get_user_full_name($uid);
						$condition_name = translate_condition($condition);

						echo "<tr>";
							
						show_user_hyper_link($nick_name, $uid);

						echo "<td>";
						echo $full_name;
						echo "</td>";

						echo "<td>";
						echo $condition_name;
						echo "</td>";
							
						show_friend_or_care_td($uid);

						echo "</tr>";
					}
				}

			}
			?>
		</table>
	</center>

</body>
</html>
